Conditions | 1 |
Paths | 1 |
Total Lines | 81 |
Code Lines | 44 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | // Base path --> assets/html |
||
23 | $(document).ready(function() { // When document is ready |
||
24 | ipcRenderer.send('app:debug', "Document is ready"); |
||
25 | |||
26 | startup(); |
||
27 | |||
28 | // Button/Toggle special menu items |
||
29 | $('#navButtonExtendedmenu').click(function() { |
||
30 | ipcRenderer.send('app:debug', "#navButtonExtendedmenu was clicked"); |
||
31 | $('#navButtonExtendedmenu').toggleClass('is-active'); |
||
32 | $('.is-specialmenu').toggleClass('is-hidden'); |
||
33 | }); |
||
34 | |||
35 | // Window minimize button |
||
36 | $('#navButtonMinimize').click(function() { |
||
37 | ipcRenderer.send('app:debug', "#navButtonMinimize was clicked"); |
||
38 | remote.getCurrentWindow().minimize(); |
||
39 | }); |
||
40 | |||
41 | // Window exit button |
||
42 | $('#navButtonExit').click(function() { |
||
43 | ipcRenderer.send('app:debug', "#navButtonExit was clicked"); |
||
44 | remote.getCurrentWindow().close(); |
||
45 | }); |
||
46 | |||
47 | // Assign [ESC] to close message/modal |
||
48 | $(document).keyup(function(event) { |
||
49 | if (event.keyCode === 27) { |
||
50 | ipcRenderer.send('app:debug', "Used [ESC] key, {0}".format(event.keyCode)); |
||
51 | if ($('#swMessageWhois').hasClass('is-active')) { |
||
52 | $('#swMessageWhoisClose').click(); |
||
53 | } else if ($('.notification')) { |
||
54 | $('.notification:not(.is-hidden)').addClass('is-hidden'); |
||
55 | if ($('#swTableWhoisInfo:not(.is-hidden)')) { |
||
56 | $('#swTableWhoisInfo').addClass('is-hidden'); |
||
57 | } |
||
58 | } |
||
59 | } |
||
60 | }); |
||
61 | |||
62 | // Prevent drop redirect |
||
63 | $(document).on('drop', function(event) { |
||
64 | ipcRenderer.send('app:debug', "Preventing drag and drop redirect"); |
||
65 | event.preventDefault(); |
||
66 | return false; |
||
67 | }); |
||
68 | |||
69 | // Prevent drag over redirect |
||
70 | $(document).on('dragover', function(event) { |
||
71 | event.preventDefault(); |
||
72 | return false; |
||
73 | }); |
||
74 | |||
75 | // Toggle devtools |
||
76 | $('#navButtonDevtools').click(function() { |
||
77 | remote.getCurrentWindow().toggleDevTools(); |
||
78 | ipcRenderer.send('app:debug', "#navButtonDevtools was clicked"); |
||
79 | }); |
||
80 | |||
81 | // Toggle between tabs |
||
82 | $('section.tabs ul li').click(function() { |
||
83 | var tabName = $(this).attr('data-tab'); |
||
84 | |||
85 | if (tabName != '#') { |
||
86 | $('section.tabs ul li').removeClass('is-active'); |
||
87 | $('div.container .tab-content').removeClass('current'); |
||
88 | |||
89 | $(this).addClass('is-active'); |
||
90 | $("#" + tabName).addClass('current'); |
||
91 | } |
||
92 | ipcRenderer.send('app:debug', "#section.tabs switched to data tab, {0}".format(tabName)); |
||
93 | }); |
||
94 | |||
95 | // Delete notifications |
||
96 | $('.delete').click(function() { |
||
97 | ipcRenderer.send('app:debug', ".delete (notifications) was clicked"); |
||
98 | var notificationId = $(this).attr('data-notif'); |
||
99 | |||
100 | $('#' + notificationId).addClass('is-hidden'); |
||
101 | }); |
||
102 | |||
103 | }); |
||
104 | |||
132 |